<? 

require('./includes/config.php');
include "./includes/libchart/classes/libchart.php";
require('./includes/func_database.php');

$dbh = initConnection();

$chart = new LineChart(2000, 500);
	

$dataSet = new XYDataSet();

$shinobu_points = selectMultiQuery("SELECT date_time, raid_points.raid_id, class_id, Sum( rp_gained ) AS 'gained', Sum( rp_spend ) AS 'spend'
FROM raid_points
INNER JOIN raid ON raid.raid_id = raid_points.raid_id
INNER JOIN player ON raid_points.player_id = player.player_id
WHERE player.class_id =1
AND category_id =4
GROUP BY raid_id, player.class_id
ORDER BY date_time
", $dbh);

$total = 0;

foreach ($shinobu_points as $point) {

	$total = $total + $point['gained'] - $point['spend'];
	
	$dataSet->addPoint(new Point($point['date_time'], $total));
	
}



$chart->setDataSet($dataSet);

$chart->getPlot()->setGraphCaptionRatio(0.62);

$chart->setTitle("RP Statistics for: Mages");
$chart->render("./images/mages.png");

echo "<img src='./images/mages.png'></img>"

?>